package tech.lixinlei.current.optional.map;

import tech.lixinlei.current.optional.map.bo.Car;
import tech.lixinlei.current.optional.map.bo.Insurance;
import tech.lixinlei.current.optional.map.bo.Person;

import java.util.Optional;

public class OptionalMapDemo01 {

    public static void main(String[] args) {
        Person person = new Person();
        Optional<Person> optional = Optional.ofNullable(person);
        Optional<Car> car = optional.map(Person::getCar);
        Optional<Insurance> insurance = car.map(Car::getInsurance);
        Optional<String> s = insurance.map(Insurance::getName);
        System.out.println(s.orElse("空"));
    }

}
